#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int MAXN=550;
int dp[MAXN][MAXN];
int main(void){
	int al=5;
	int a[]={-1000,1,4,2,5,-12};
	int bl=4;
	int b[]={-1000,-12,1,2,4};
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=al;i++){
		for(int j=1;j<=bl;j++){
		//主要就是这个状态转移方程
			if(a[i]==b[j]){
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else{
				dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
			}
		}
	}
	printf("%d\n",dp[al][bl]);
    return 0;
}
